package company.meituan;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

/**
 * 美团编程笔试1
 *
 * @author briarbear
 * @blog https://briarbear.github.io
 * @date 2018-09-06 18:54
 */
public class M1 {

    static LinkedList<LinkedList<Integer>> links;
    static int res = 0;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            int N = scanner.nextInt();
            links = new LinkedList<>();
            for (int i = 0; i <= N; i++) {
                links.add(new LinkedList<>());
            }
            for (int i = 0; i < N - 1; i++) {
                int x = scanner.nextInt();
                int y = scanner.nextInt();
                links.get(x).add(y);
                links.get(y).add(x);
            }

            helper(0,1,0);
            System.out.println(2*(N-1)-res);
        }
    }

    public static void helper(int a,int b,int step){
        int len = links.get(b).size();
        if (len == 1 && a != 0){
            res = Math.max(step,res);
            return;
        }

        for (int i = 0; i < len; i++) {
            int value = links.get(b).get(i);
            if (value == a) continue;
            helper(b,value,step+1);
        }
    }




}
